<?php
/* 
 * ********* CVS HEADER ********* 
 * 
 * $RCSfile: admusermouv.php,v $ 
 * $Date: 2005/08/29 15:30:42 $ 
 * $Revision: 1.2 $ 
 * 
 * ********* CVS HEADER ********* 
 */
if ($mouvgroup != 0) {
	$query = "DELETE FROM session WHERE id_user='$argid'";
	@ rportalrequete($query) or die("ERREUR 0154");
	$query = "UPDATE utilisateur SET id_groupe='$mouvgroup' WHERE id='$argid'";
	@ rportalrequete($query) or die("ERREUR 0153");
	header("Location: ?op=admuseraff&argid=$argid");
} else {
	if ($mouvseq != 0) {
		$groupdefseq = $rportalparams->get_value("RPORTAL","groupe.sequenceur");
		$query = "SELECT login,id_groupe FROM utilisateur WHERE id='$argid'";
		$result = rportalrequete($query) or die("ERREUR 0114");
		if ($row = rportalligne($result)) {
			$user_login = $row["login"];
			$user_groupe = $row["id_groupe"];
		}
		//On recupere les donnees sur la sequence a executer
		$query = "SELECT id FROM sequence_ordre WHERE id_sequence='$mouvseq' ORDER BY id";
		$result = rportalrequete($query) or die("ERREUR 0114");
		$etape = -1;
		if ($row = rportalligne($result)) {
			$etape = $row[id];
		}
		$query = "INSERT INTO sequence_status (login,id_groupe,etape,id_sequence)";
		$query.=" VALUES ('$user_login','$user_groupe','$etape','$mouvseq')";
		$result = rportalrequete($query) or die("ERREUR 0115");
		$query = "DELETE FROM session WHERE id_user='$argid'";
		$result = rportalrequete($query) or die("ERREUR 0065");
		$query = "UPDATE utilisateur SET id_groupe='$groupdefseq' WHERE id='$argid'";
		$result = rportalrequete($query) or die("ERREUR 0064");
		header("Location: ?op=admuseraff&argid=$argid");
	} else {
		include ("session/erreur404.php");
	}
}
?>